(function($){

    $.heyflow.Modules.CUSR23={
        LastFilters:'',
        init:function(){
            self=$h.Modules.CUSR23;
            $.heyflow.Toolbar.show();
            $('#detailpad').hide();
            $('#datapad').html('<table id="cusr23"></table>');
            $.get('/api/cus/cusr23',{t:$.heyflow.Token.get(),f:1},function(d){
                    if (d.STATUS==200){
                        d=d.DATA;
                        //$.heyflow.Modules.CUSR23.module=d;
                        d.datatype='local';
                        d.rowNum=50;
                        d.viewrecords=true;
                        d.cellsubmit='clientArray';
                        //d.height='100%';
                        $("#cusr23").jqGrid(d);}
                    ;},'json');
            //$.heyflow.Modules.CUSR23=$.heyflow.Modules.CUSR23;
            $.heyflow.ActiveModule=$.heyflow.Modules.CUSR23;
            ;},
        search:function(name){
            //console.log('self',self);
            self=$h.Modules.CUSR23;
            console.log('self1',self);
            $("#cusr23").jqGrid('searchGrid', {
                    multipleSearch:true,
                    dataUrl:'select',
                    closeAfterSearch:true,
                    afterShowSearch:function(d){
                        console.log('search show');
                        ;},
                    onSearch:function(){
                        var p=$('#cusr23')[0].p.postData;
                        filters=p.filters;
                        self.LastFilters=filters;
                        p.filters='';
                        self.dosearch(filters);
                        ;}})},
        dosearch:function(filters){
            var i,j,n,nn=$('#cusr23').jqGrid('getGridParam','colModel');
            
            $('#cusr23').jqGrid('clearGridData');
            $.get('/api/cus/cusr23',{t:$h.Token.get(),ft:filters},function(d){
                if (d.STATUS==200){
                    d=d.DATA;
                    for (i in d[1]){
                        r={};
                        for (j in nn){
                            r[nn[j].name]=d[1][i][j]
                            ;}
                        $('#cusr23').addRowData(String(i+1),r);}}
                ;},'json');
            ;},
        export:function(){
            var p=$('#cusr23')[0].p.postData;
            filters=p.filters;
            console.log(filters,self.LastFilters);
            //window.open('/api/cus/export?t=%s&m=cusr23');
            //window.location
            url="/api/cus/export?t="+$h.Token.get()+"&m=cusr23&f="+self.LastFilters;

            //reportOut(url);
            //www.baidu.com/test.rar"
            ;}
    }

})(jQuery);